package com.yunxin.utils.db;

import lombok.Builder;
import lombok.Data;

import java.sql.Connection;
import java.sql.SQLException;

@Data
@Builder
public class DBConnectionBuilder {
    private String driverClass;
    private String url;
    private String username;
    private String password;

    public DBConnection build() throws ClassNotFoundException, SQLException {
        DBUtil.initDatabaseDriver(driverClass);
        Connection connection = DBUtil.buildConnection(url,username,password);
        DBConnection dbConnection = new DBConnection();
        dbConnection.setConnection(connection);
        return dbConnection;
    }
}
